<template>
  <div class="expert-layout">
    <!-- 顶部栏 -->
    <div class="top-bar">
      <div class="welcome-section">
        <el-avatar :size="36" style="background-color: white; color: #409eff; margin-right: 12px;">
          <i class="el-icon-user-solid"></i>
        </el-avatar>
        <div>
          <div class="welcome-text">欢迎回来</div>
          <div class="role-text">专家</div> 
        </div>
      </div>

      <div class="title-section">
        <div class="logo-container">
          <img
            src="@/assets/logo.png"
            alt="logo"
            height="40"
            class="logo-img"
          />
        </div>
        <div class="title-text">
          <div class="system-title">询标系统</div>
          <div class="system-subtitle">专家端</div>
        </div>
      </div>

      <div class="time-section">
        <el-card class="time-card" shadow="never">
          <div style="display: flex; align-items: center;">
            <i class="el-icon-time" style="color: white; margin-right: 8px;"></i>
            <div>
              <!-- <div class="time-label">当前时间</div> -->
              <div class="time-display">{{ currentTime }}</div>
            </div>
          </div>
        </el-card>
      </div>
    </div>

    <!-- 主要内容区 -->
    <div class="main-content">
      <div class="content-wrapper">
        <div class="content-container">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default { 
  name: 'ExpertLayout',
  data() {
    return {
      currentTime: '',
      timeTimer: null
    }
  },
  methods: {
    updateCurrentTime() {
      const d = new Date();
      const y = d.getFullYear();
      const m = String(d.getMonth() + 1).padStart(2, '0');
      const day = String(d.getDate()).padStart(2, '0');
      const hh = String(d.getHours()).padStart(2, '0');
      const mm = String(d.getMinutes()).padStart(2, '0');
      const ss = String(d.getSeconds()).padStart(2, '0');
      this.currentTime = `${y}年${m}月${day}日 ${hh}:${mm}:${ss}`;
    }
  },
  mounted() {
    // 立即更新一次时间
    this.updateCurrentTime();
    // 每秒更新时间显示
    this.timeTimer = setInterval(() => {
      this.updateCurrentTime();
    }, 1000);
  },
  beforeDestroy() {
    if (this.timeTimer) {
      clearInterval(this.timeTimer);
    }
  }
}
</script>

<style scoped>
.expert-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: 64px;
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 0 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.6, 1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.welcome-section {
  width: 200px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.welcome-section:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.welcome-text {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.role-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.title-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-container {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px;
  margin-right: 16px;
  transition: all 0.3s ease;
}

.logo-container:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(5deg) scale(1.05);
}

.logo-img {
  vertical-align: middle;
  transition: all 0.3s ease;
}

.title-text {
  text-align: left;
}

.system-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.system-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.time-section {
  width: 200px;
  display: flex;
  justify-content: flex-end;
}

.time-card {
  background: rgba(255, 255, 255, 0.1) !important;
  border-radius: 12px !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  transition: all 0.3s ease;
  padding: 8px !important;
}

.time-card:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.time-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.time-display {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.main-content {
  flex: 1;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: calc(100vh - 64px);
  margin-top: 64px;
  position: relative;
}

.main-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.content-wrapper {
  position: relative;
  z-index: 1;
  backdrop-filter: blur(20px);
  min-height: 100%;
}

.content-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 960px) {
  .welcome-section,
  .time-section {
    width: auto;
    min-width: 120px;
  }
  
  .title-text {
    text-align: center;
  }
  
  .logo-container {
    margin-right: 8px;
  }
  
  .top-bar {
    padding: 0 16px;
  }
}

@media (max-width: 768px) {
  .welcome-section {
    display: none;
  }
  
  .time-section {
    display: none;
  }
  
  .title-section {
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .content-container {
    padding: 16px;
  }
  
  .top-bar {
    padding: 0 12px;
  }
  
  .logo-container {
    margin-right: 8px;
    padding: 6px;
  }
  
  .system-title {
    font-size: 16px;
  }
  
  .system-subtitle {
    font-size: 11px;
  }
}

/* 深色主题支持 */
.theme--dark .main-content {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.theme--dark .content-wrapper {
  backdrop-filter: blur(10px);
}

/* 滚动条美化 */
.main-content ::-webkit-scrollbar {
  width: 8px;
}

.main-content ::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.main-content ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  transition: all 0.3s ease;
}

.main-content ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}
</style>